# 5.1.1字典的创建方式
# 1.使用大括号'{}'创建字典
{'name':'小明', 'age':21, 'address':'北京'}
# 2.使用dict()函数创建字典
dict(name='小明',age=21,address='北京')

# 5.1.2通过键访问字典
color_dict = {'purple':'紫色','green':'绿色','black':'黑色'}
print(color_dict['purple'])
print(color_dict['green'])
print(color_dict['black'])
print(color_dict['red'])
if 'red' in color_dict:
    print(color_dict['red'])
else:
    print('键不存在')
